/**
 * 报考专业管理初始化
 */
var EnrollSchoolBatchMajor = {
    id: "EnrollSchoolBatchMajorTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
EnrollSchoolBatchMajor.initColumn = function () {
    return [
            {title: '报考专业代号', field: 'majorCode', visible: true, align: 'center', valign: 'middle'},
            {title: '报考专业名称', field: 'majorName', visible: true, align: 'center', valign: 'middle'},
            {title: '所属志愿批次', field: 'batchType', visible: true, align: 'center', valign: 'middle' ,formatter:changeBatch} ,
            {title: '专业学制', field: 'schoolLength', visible: true, align: 'center', valign: 'middle'}
    ];
};

    function changeBatch(value ,row ,index ){
        if(value =='1'){return "提前录取(师范)" ;}
        if(value =='2'){return "指标生录取(第一阶段)" ;}
        if(value =='3'){return "提前录取(普高)"  ;}
        if(value =='4'){return "第一批录取(普高)" ;}
        if(value =='5'){ return "第一批录取(现代职教试点)";}
        if(value =='6'){return "第二批录取(普高)" ;}
        if(value =='7'){return "第三批录取(对口单招)" ;}
        if(value =='8'){return "第四批录取(省部属学校)艺术类提前录取" ;}
        if(value =='9'){return "第四批录取(省部属学校)五年制高职、“3+3”现代职教试点项目" ;}
        if(value =='10'){return "第四批录取(省部属学校)三四年制中专" ;}
        if(value =='11'){return "第五批录取(市属中专、技校)" ;}
        if(value =='12'){return "统配录取(其他市属中专、技工学校)" ;}
        if(value =='13'){return "指标生录取(第二阶段)" ;}

    }

/**
 * 检查是否选中
 */
EnrollSchoolBatchMajor.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        EnrollSchoolBatchMajor.seItem = selected[0];
        return true;
    }
};

/**
 * 点击添加报考专业
 */
EnrollSchoolBatchMajor.openAddEnrollSchoolBatchMajor = function () {
    var index = layer.open({
        type: 2,
        title: '添加报考专业',
        area: ['768px', '320px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/enrollSchoolBatchMajor/enrollSchoolBatchMajor_add/'+$("#enrollSchoolId").val()
    });
    this.layerIndex = index;
};

/**
 * 打开查看报考专业详情
 */
EnrollSchoolBatchMajor.openEnrollSchoolBatchMajorDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '报考专业详情',
            area: ['768px', '320px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/enrollSchoolBatchMajor/enrollSchoolBatchMajor_update/' + EnrollSchoolBatchMajor.seItem.id
        });
        this.layerIndex = index;
    }
};

/**
 * 删除报考专业
 */
EnrollSchoolBatchMajor.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/enrollSchoolBatchMajor/delete", function (data) {
            Feng.success("删除成功!");
            EnrollSchoolBatchMajor.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("enrollSchoolBatchMajorId",this.seItem.id);
        ajax.start();
    }
};

/**
 * 查询报考专业列表
 */
EnrollSchoolBatchMajor.search = function () {
    var queryData = {};
    queryData['condition'] = $("#condition").val();
    EnrollSchoolBatchMajor.table.refresh({query: queryData});
};


EnrollSchoolBatchMajor.resetSearch = function () {
    $("#condition").val("");
    EnrollSchoolBatchMajor.search();
};

$(function () {
    var defaultColumns = EnrollSchoolBatchMajor.initColumn();
    var table = new BSTable(EnrollSchoolBatchMajor.id, "/enrollSchoolBatchMajor/list/"+$("#enrollSchoolId").val(), defaultColumns);
    EnrollSchoolBatchMajor.table = table.init();
});
